package cjyyp.netty中futrue和promise接口;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

@Slf4j
public class 使用jdk中的future {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService fixedThreadPool = Executors.newFixedThreadPool(2);
        Future<Integer> jdkFuture = fixedThreadPool.submit(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                Thread.sleep(1000);
                log.info("执行中。。。");
                return 20;
            }
        });
        log.info("结果是[{}]",jdkFuture.get());
        fixedThreadPool.shutdown();
    }
}
